<layout name="layout"/>


<div class="panel admin-panel">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
    <div class="body-content">
        <form name="main_form" class="form-x" id="myform" method="POST" action="__SELF__" enctype="multipart/form-data">
            <input type="hidden" name="userid" value="admin">
            <div class="form-group">
                <div class="label">
                    <label>会员时长：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="<?php echo $data['name']?>" placeholder="一个月" name="name"
                    />
                    <div class="tips"></div>
                </div>
            </div>
            <input type="hidden" name="id" value="{:I('get.id')}">
            <div class="form-group" id="sj">
                <div class="label">
                    <label>会员价格：</label>
                </div>
                <div class="field">
                    <input type="text" id="money" placeholder="10"  class="input w35" value="<?php echo $data['money']?>" name="money"/>
                    <label>元</label>
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <input id="submit" type="button" value="提交" class="button bg-blue">
                    <input type="reset" value="重置" class="button bg-red">
                    <input type="button" value="取消" onclick="javascript :history.back(-1)" class="button bg-blue">
                </div>
            </div>
        </form>
    </div>
</div>
<script src="__PUBLIC__/layui/layui.all.js"></script>
<script>
    $("#submit").click(function () {
        var data = $("#myform").serialize();
        console.log(data);
        if ($("input[name='name']").val() == '' || $("input[name='name']").val() == undefined) {
            alert('会员时长不能为空');
            return false;
        }
        if ($("input[name='money']").val() == '' || $("input[name='money']").val() == undefined) {
            alert('会员价格不能为空');
            return false;
        }
        $.post("<?php echo U('edit')?>", data, function (res) {
            alert(res.info);
            location.href = res.url;
        })
    })

</script>

